/**
 * TODO <br>
 * 0.2: weijj:2019年5月11日 下午3:33:41:TODO <br>
 * @author  weijj
 * @since 2019年5月11日 下午3:33:41
 * @date 2019年5月11日 下午3:33:41
 * @version 0.1 初始为0.1,后续变更则修改
 */
package com.fdb.efp.nls.service.impl.dw;

import com.fdb.basic.framework.core.constant.MonAlrmLvlEnums.MonAlrmLvlEnum;
import com.fdb.basic.framework.core.util.DateTool;
import com.fdb.efp.nls.common.constant.BdLoanConstant;
import com.fdb.efp.nls.service.domain.TxtFileLoadBean;
import com.fdb.efp.nls.service.domain.dw.DwBaiduRepayPlanBean;
import com.fdb.efp.nls.service.facade.dw.DwBaiduRepayPlanBatchService;
import com.fdb.efp.nls.service.util.DueDataUtil;
import com.fdb.efp.nls.service.util.SDicMappingUtil;
import com.fdb.efp.nls.service.util.TxtFileLoadPluginBatch;
import com.fdb.efp.nls.service.facade.AccoutErroTempService;
import com.fdb.efp.nls.service.facade.DwBaiduRepayPlanTempService;
import com.fdb.efp.nls.service.facade.LoanRepayPlanService;
import com.fdb.efp.nls.service.vo.AccoutErroTempVO;
import com.fdb.efp.loan.service.vo.LoanRepayPlanVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 根据百度同步过来的日初借据分期计划临时表数据修改还款计划表
 * 
 * @author weijj
 * @since 2019年5月11日 下午3:33:41
 * @version 1.0
 */
@Service("dwBaiduRepayPlanBatchService")
public class DwBaiduRepayPlanBatchServiceImpl implements DwBaiduRepayPlanBatchService {

	private static Logger logger = LoggerFactory.getLogger(DwBaiduRepayPlanBatchServiceImpl.class);

	@Autowired
	@Qualifier("dwBaiduRepayPlanTempService")
	private DwBaiduRepayPlanTempService dwBaiduRepayPlanTempService;// 日初借据分期计划表

	@Autowired
	@Qualifier("accLoanRepayPlanService")
	private LoanRepayPlanService loanRepayPlanService;// 贷款计划表

	@Autowired
	@Qualifier("accoutErroTempService")
	private AccoutErroTempService accoutErroTempService;// 错误信息
	//
	// /**
	// * 根据百度同步过来的日初借据分期计划临时表数据修改还款计划表 <br>
	// * 0.1: weijj:2019年5月11日 下午3:36:13:新增 <br>
	// *
	// * @author weijj
	// * @since 2019年5月11日 下午3:36:13
	// * @date 2019年5月11日 下午3:36:13
	// * @version 0.1
	// */
	// @Override
	// public boolean batchUpdateDwBaiduRepayPlan() throws Exception {
	// boolean result = false;
	// long startTime = System.currentTimeMillis();
	// logger.info("同步过来的日初借据分期计划临时表数据修改还款计划表：[" + DateTool.formatDate(new
	// Date(startTime), DateTool.PATTERN_DATETIME) + "]， 处理开始！");
	// // 可以配置参数
	// Integer pageSize = 1000;
	// try {
	// // 单位转换
	// final int oneHundred100 = 100;
	// // 需要新增或者修改的还款计划表
	// List<LoanRepayPlanVO> list = null;
	// // 分页信息
	// DwBaiduRepayPlanTempVO pageInfo = new DwBaiduRepayPlanTempVO();
	// // 新增或者修改的还款计划表
	// int num = 0;
	// // 页数
	// int page = 1;
	// // pageSize初始化
	// if (pageSize > 0) {
	// pageInfo.setSize(pageSize);
	// } else {
	// pageInfo.setSize(1000);
	// }
	// // 判断循环次数
	// int size = dwBaiduRepayPlanTempService.queryCount();
	// String size_msg = "【还款计划表】数据量：" + size;
	// logger.info(size_msg, "message{}");
	// int loopCount = (size / pageInfo.getSize()) + 1;
	// for (int i = 0; i < loopCount; i++) {
	// // 分页查询【还款计划表】数据
	// List<DwBaiduRepayPlanTempVO> tempList =
	// dwBaiduRepayPlanTempService.queryByPage(pageInfo);
	// list = new ArrayList<LoanRepayPlanVO>();
	// if (tempList != null && !tempList.isEmpty()) {
	// for (DwBaiduRepayPlanTempVO dwBaiduRepayPlanTempVO : tempList) {
	// // 还款计划表
	// LoanRepayPlanVO loanRepayPlanVO = new LoanRepayPlanVO();
	// loanRepayPlanVO.setBizDate(DueDataUtil.dateInfoTrans(dwBaiduRepayPlanTempVO.getCurDate()));
	// // prd_code 产品代码
	// loanRepayPlanVO.setProductCd(
	// SDicMappingUtil.getLocalSysDicVal(BdLoanConstant.PRD_CODE,
	// dwBaiduRepayPlanTempVO.getProdtp()));
	// loanRepayPlanVO.setRefNbr(dwBaiduRepayPlanTempVO.getLoanId());
	// loanRepayPlanVO.setTerm(dwBaiduRepayPlanTempVO.getTermNo().intValue());
	// loanRepayPlanVO.setBeginDate(DueDataUtil.dateInfoTrans(dwBaiduRepayPlanTempVO.getStartDate()));
	// loanRepayPlanVO.setStmtDate(DueDataUtil.dateInfoTrans(dwBaiduRepayPlanTempVO.getEndDate()));
	// loanRepayPlanVO.setGraceDate("");
	// loanRepayPlanVO.setStatus(
	// SDicMappingUtil.getLocalSysDicVal(BdLoanConstant.TERM_STATUS,
	// dwBaiduRepayPlanTempVO.getTermStatus()));
	// // 逾期
	// if
	// (BdLoanConstant.TERM_STATUS_2.equals(dwBaiduRepayPlanTempVO.getTermStatus()))
	// {
	// // 违约标志
	// loanRepayPlanVO.setOverdueFlag(BdLoanConstant.YES_1);
	// } else {
	// loanRepayPlanVO.setOverdueFlag(BdLoanConstant.NO_0);
	// }
	// loanRepayPlanVO.setPrincipal(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getPrinTotal(),
	// oneHundred100));
	// loanRepayPlanVO.setPrincipalDue(BigDecimal.ZERO);
	// loanRepayPlanVO.setPrincipalPaid(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getPrinRepay(),
	// oneHundred100));
	// loanRepayPlanVO.setPrincipalDue91(BigDecimal.ZERO);
	// loanRepayPlanVO.setInterest(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getIntTotal(),
	// oneHundred100));
	// loanRepayPlanVO.setInterestPaid(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getIntRepay(),
	// oneHundred100));
	// loanRepayPlanVO.setInterestDue(BigDecimal.ZERO);
	// loanRepayPlanVO.setInterestDue91(BigDecimal.ZERO);
	// loanRepayPlanVO.setPenaltyDue(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getPnltIntTotal(),
	// oneHundred100));
	// loanRepayPlanVO.setPenaltyPaid(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getPnltIntRepay(),
	// oneHundred100));
	// loanRepayPlanVO.setInitTerm(0);
	// loanRepayPlanVO.setClearDate(DueDataUtil.dateInfoTrans(dwBaiduRepayPlanTempVO.getClearDate()));
	// loanRepayPlanVO.setFundFeeTotal(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getFundFeeTotal(),
	// oneHundred100));
	// loanRepayPlanVO.setFundFeeRepay(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getFundFeeRepay(),
	// oneHundred100));
	// loanRepayPlanVO.setIntReducedAmtCoupon(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getIntReducedAmt(),
	// oneHundred100));
	// loanRepayPlanVO
	// .setPnltReducedAmtCoupon(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getPnltReducedAmt(),
	// oneHundred100));
	// loanRepayPlanVO
	// .setFundFeeReducedAmtCoupon(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getFundFeeReducedAmt(),
	// oneHundred100));
	// loanRepayPlanVO.setChargesTotal(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getChargesTotal(),
	// oneHundred100));
	// loanRepayPlanVO.setChargesRepay(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getChargesRepay(),
	// oneHundred100));
	// loanRepayPlanVO.setOverdueTotal(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getOverdueTotal(),
	// oneHundred100));
	// loanRepayPlanVO.setOverdueRepay(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getOverdueRepay(),
	// oneHundred100));
	// loanRepayPlanVO
	// .setRepayViolateTotal(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getRepayViolateTotal(),
	// oneHundred100));
	// loanRepayPlanVO
	// .setRepayViolateRepay(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getRepayViolateRepay(),
	// oneHundred100));
	// loanRepayPlanVO
	// .setRefundViolateTotal(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getRefundViolateTotal(),
	// oneHundred100));
	// loanRepayPlanVO
	// .setRefundViolateRepay(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getRefundViolateRepay(),
	// oneHundred100));
	// loanRepayPlanVO.setServiceTotal(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getServiceTotal(),
	// oneHundred100));
	// loanRepayPlanVO.setServiceRepay(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getServiceRepay(),
	// oneHundred100));
	// loanRepayPlanVO.setChargesReducedAmtCoupon(
	// DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getChargesReducedAmtCoupon(),
	// oneHundred100));
	// loanRepayPlanVO.setOverdueReducedAmtCoupon(
	// DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getOverdueReducedAmtCoupon(),
	// oneHundred100));
	// loanRepayPlanVO.setRepayViolateReducedAmtCoupon(
	// DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getRepayViolateReduAmtCoupon(),
	// oneHundred100));
	// loanRepayPlanVO.setRefundViolateReducedAmtCoupon(
	// DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getRefundViolateReduAmtCoupon(),
	// oneHundred100));
	// loanRepayPlanVO.setServiceReducedAmtCoupon(
	// DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getServiceReducedAmtCoupon(),
	// oneHundred100));
	// loanRepayPlanVO
	// .setPrinReducedAmtManual(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getPrinReducedAmtManual(),
	// oneHundred100));
	// loanRepayPlanVO
	// .setIntReducedAmtManual(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getIntReducedAmtManual(),
	// oneHundred100));
	// loanRepayPlanVO
	// .setPnltReducedAmtManual(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getPnltReducedAmtManual(),
	// oneHundred100));
	// loanRepayPlanVO.setFundFeeReducedAmtManual(
	// DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getFundFeeReducedAmtManual(),
	// oneHundred100));
	// loanRepayPlanVO.setChargesReducedAmtManual(
	// DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getChargesReducedAmtManual(),
	// oneHundred100));
	// loanRepayPlanVO.setOverdueReducedAmtManual(
	// DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getOverdueReducedAmtManual(),
	// oneHundred100));
	// loanRepayPlanVO.setRepayViolateReducedAmtManual(
	// DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getRepayViolateReduAmtManual(),
	// oneHundred100));
	// loanRepayPlanVO.setRefundViolateReducedAmtManual(
	// DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getRefundViolateReduAmtManual(),
	// oneHundred100));
	// loanRepayPlanVO.setServiceReducedAmtManual(
	// DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanTempVO.getServiceReducedAmtManual(),
	// oneHundred100));
	// list.add(loanRepayPlanVO);
	// }
	// // 需要新增或者更新的还款计划表
	// if (list != null && !list.isEmpty()) {
	// int updateSize = loanRepayPlanService.insertOrUpdateLoanRepayPlan(list);
	// num += updateSize;
	// }
	// }
	// pageInfo.setPage(++page);
	// }
	// String num_msg = "【还款计划表】插入或更新数据处理结果:" + num;
	// logger.info(num_msg, "message{}");
	// result = true;
	// } catch (Exception e) {
	// e.printStackTrace();
	// String tableName = "loan_repay_plan";
	// String errorMsg = "同步过来的日初借据分期计划临时表数据修改还款计划表出错！";
	// String remark = "同步过来的日初借据分期计划临时表数据修改还款计划表出错，错误信息：" + e.getMessage();
	// addErrorInfo(tableName, MonAlrmLvlEnum.SERIOUS.getEnname(), errorMsg,
	// remark);
	// logger.error(remark);
	// throw new Exception(remark);
	// }
	// long endTime = System.currentTimeMillis();
	// logger.info("同步过来的日初借据分期计划临时表数据修改还款计划表：[" + DateTool.formatDate(new
	// Date(endTime), DateTool.PATTERN_DATETIME) + "]， 处理结束！");
	// logger.info("SERIOUS，耗时：[" + (endTime - startTime) / 1000.0 + "]秒，处理结果[" +
	// result + "]");
	// return result;
	// }

	/**
	 * 根据百度同步过来的日初借据分期计划文件数据信息修改还款计划表 <br>
	 * 0.1: weijj:2019年5月23日 下午9:27:00:新增 <br>
	 * 
	 * @author weijj
	 * @since 2019年5月23日 下午9:27:00
	 * @date 2019年5月23日 下午9:27:00
	 * @version 0.1
	 */
	@Override
	public boolean batchUpdateDwBaiduRepayPlan(String fileUrl) throws Exception {
		// 处理结果
		boolean result = false;
		long startTime = System.currentTimeMillis();
		logger.info("同步过来的日初借据分期计划临时表数据修改还款计划表：[" + DateTool.formatDate(new Date(startTime), DateTool.PATTERN_DATETIME) + "]， 处理开始！");
		try {
			TxtFileLoadPluginBatch txtFileLoadPlugin = new TxtFileLoadPluginBatch(fileUrl, "\u0002", "UTF-8", 0, 1000);
			List<TxtFileLoadBean> txtFileLoadList = txtFileLoadPlugin.run(new DwBaiduRepayPlanBean());
			result = dueData(txtFileLoadList);
			if (txtFileLoadList.size() != 0) {
				while (!txtFileLoadList.get(txtFileLoadList.size() - 1).isReadedComplete) {
					txtFileLoadPlugin.setFirstRead(false);
					txtFileLoadList = txtFileLoadPlugin.run(new DwBaiduRepayPlanBean());
					if (txtFileLoadList.size() == 0) {
						break;
					}
					result = dueData(txtFileLoadList);
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			String tableName = "loan_repay_plan";
			String errorMsg = "同步过来的日初借据分期计划临时表数据修改还款计划表出错！";
			String remark = "同步过来的日初借据分期计划临时表数据修改还款计划表出错，错误信息：" + e.getMessage();
			addErrorInfo(tableName, MonAlrmLvlEnum.SERIOUS.getEnname(), errorMsg, remark);
			logger.error(remark);
			throw new Exception(remark);
		}
		long endTime = System.currentTimeMillis();
		logger.info("同步过来的日初借据分期计划临时表数据修改还款计划表：[" + DateTool.formatDate(new Date(endTime), DateTool.PATTERN_DATETIME) + "]， 处理结束！");
		logger.info("SERIOUS，耗时：[" + (endTime - startTime) / 1000.0 + "]秒，处理结果[" + result + "]");
		return result;
	}

	/**
	 * 
	 * 根据百度同步过来的日初借据分期计划文件数据信息加工初始化还款计划信息<br>
	 * 0.1:weijj:2019年6月3日 下午7:37:25:新增 <br>
	 * 
	 * @author weijj
	 * @since 2019年6月3日 下午7:37:25
	 * @date 2019年6月3日 下午7:37:25
	 * @version 0.1
	 */
	public boolean dueData(List<TxtFileLoadBean> txtFileLoadList) {
		logger.info("同步过来的日初借据分期计划临时表数据修改还款计划表加工处理开始！");
		// 需要新增或者修改的还款计划表
		List<LoanRepayPlanVO> list = new ArrayList<LoanRepayPlanVO>();
		// 处理结果
		boolean result = false;
		// 新增或者修改的数量
		int num = 0;
		// 单位转换
		final int oneHundred100 = 100;
		DwBaiduRepayPlanBean dwBaiduRepayPlanBean = new DwBaiduRepayPlanBean();
		try {
			for (int i = 0; i < txtFileLoadList.size(); i++) {
				dwBaiduRepayPlanBean = (DwBaiduRepayPlanBean) txtFileLoadList.get(i);
				// 还款计划表
				LoanRepayPlanVO loanRepayPlanVO = new LoanRepayPlanVO();
				loanRepayPlanVO.setBizDate(DueDataUtil.dateInfoTrans(dwBaiduRepayPlanBean.getCurDate()));
				// prd_code 产品代码 Prodtp 百度分配的机构码
				loanRepayPlanVO.setProductCd(SDicMappingUtil.getLocalSysDicVal(BdLoanConstant.PRD_CODE, dwBaiduRepayPlanBean.getProdtp()));
				loanRepayPlanVO.setRefNbr(dwBaiduRepayPlanBean.getLoanId());
				loanRepayPlanVO.setTerm(dwBaiduRepayPlanBean.getTermNo().intValue());
				loanRepayPlanVO.setBeginDate(DueDataUtil.dateInfoTrans(dwBaiduRepayPlanBean.getStartDate()));
				loanRepayPlanVO.setStmtDate(DueDataUtil.dateInfoTrans(dwBaiduRepayPlanBean.getEndDate()));
				loanRepayPlanVO.setGraceDate("");
				loanRepayPlanVO
						.setStatus(SDicMappingUtil.getLocalSysDicVal(BdLoanConstant.TERM_STATUS, dwBaiduRepayPlanBean.getTermStatus()));
				 // 逾期
				 if(BdLoanConstant.TERM_STATUS_2.equals(dwBaiduRepayPlanBean.getTermStatus())){
					 loanRepayPlanVO.setOverdueFlag(BdLoanConstant.YES_1);
				 } else {
					 loanRepayPlanVO.setOverdueFlag(BdLoanConstant.NO_0);
				 }
				loanRepayPlanVO.setPrincipal(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getPrinTotal(), oneHundred100));
				loanRepayPlanVO.setPrincipalDue(BigDecimal.ZERO);
				loanRepayPlanVO.setPrincipalPaid(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getPrinRepay(), oneHundred100));
				loanRepayPlanVO.setPrincipalDue91(BigDecimal.ZERO);
				loanRepayPlanVO.setInterest(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getIntTotal(), oneHundred100));
				loanRepayPlanVO.setInterestPaid(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getIntRepay(), oneHundred100));
				loanRepayPlanVO.setInterestDue(BigDecimal.ZERO);
				loanRepayPlanVO.setInterestDue91(BigDecimal.ZERO);
				loanRepayPlanVO.setPenaltyDue(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getPnltIntTotal(), oneHundred100));
				loanRepayPlanVO.setPenaltyPaid(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getPnltIntRepay(), oneHundred100));
				loanRepayPlanVO.setInitTerm(0);
				loanRepayPlanVO.setClearDate(DueDataUtil.dateInfoTrans(dwBaiduRepayPlanBean.getClearDate()));
				loanRepayPlanVO.setFundFeeTotal(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getFundFeeTotal(), oneHundred100));
				loanRepayPlanVO.setFundFeeRepay(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getFundFeeRepay(), oneHundred100));
				loanRepayPlanVO
						.setIntReducedAmtCoupon(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getIntReducedAmt(), oneHundred100));
				loanRepayPlanVO
						.setPnltReducedAmtCoupon(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getPnltReducedAmt(), oneHundred100));
				loanRepayPlanVO.setFundFeeReducedAmtCoupon(
						DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getFundFeeReducedAmt(), oneHundred100));
				loanRepayPlanVO.setChargesTotal(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getChargesTotal(), oneHundred100));
				loanRepayPlanVO.setChargesRepay(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getChargesRepay(), oneHundred100));
				loanRepayPlanVO.setOverdueTotal(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getOverdueTotal(), oneHundred100));
				loanRepayPlanVO.setOverdueRepay(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getOverdueRepay(), oneHundred100));
				loanRepayPlanVO
						.setRepayViolateTotal(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getRepayViolateTotal(), oneHundred100));
				loanRepayPlanVO
						.setRepayViolateRepay(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getRepayViolateRepay(), oneHundred100));
				loanRepayPlanVO
						.setRefundViolateTotal(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getRefundViolateTotal(), oneHundred100));
				loanRepayPlanVO
						.setRefundViolateRepay(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getRefundViolateRepay(), oneHundred100));
				loanRepayPlanVO.setServiceTotal(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getServiceTotal(), oneHundred100));
				loanRepayPlanVO.setServiceRepay(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getServiceRepay(), oneHundred100));
				loanRepayPlanVO.setChargesReducedAmtCoupon(
						DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getChargesReducedAmtCoupon(), oneHundred100));
				loanRepayPlanVO.setOverdueReducedAmtCoupon(
						DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getOverdueReducedAmtCoupon(), oneHundred100));
				loanRepayPlanVO.setRepayViolateReducedAmtCoupon(
						DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getRepayViolateReduAmtCoupon(), oneHundred100));
				loanRepayPlanVO.setRefundViolateReducedAmtCoupon(
						DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getRefundViolateReduAmtCoupon(), oneHundred100));
				loanRepayPlanVO.setServiceReducedAmtCoupon(
						DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getServiceReducedAmtCoupon(), oneHundred100));
				loanRepayPlanVO.setPrinReducedAmtManual(
						DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getPrinReducedAmtManual(), oneHundred100));
				loanRepayPlanVO
						.setIntReducedAmtManual(DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getIntReducedAmtManual(), oneHundred100));
				loanRepayPlanVO.setPnltReducedAmtManual(
						DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getPnltReducedAmtManual(), oneHundred100));
				loanRepayPlanVO.setFundFeeReducedAmtManual(
						DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getFundFeeReducedAmtManual(), oneHundred100));
				loanRepayPlanVO.setChargesReducedAmtManual(
						DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getChargesReducedAmtManual(), oneHundred100));
				loanRepayPlanVO.setOverdueReducedAmtManual(
						DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getOverdueReducedAmtManual(), oneHundred100));
				loanRepayPlanVO.setRepayViolateReducedAmtManual(
						DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getRepayViolateReduAmtManual(), oneHundred100));
				loanRepayPlanVO.setRefundViolateReducedAmtManual(
						DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getRefundViolateReduAmtManual(), oneHundred100));
				loanRepayPlanVO.setServiceReducedAmtManual(
						DueDataUtil.checkDecimalInfo(dwBaiduRepayPlanBean.getServiceReducedAmtManual(), oneHundred100));
				list.add(loanRepayPlanVO);

			}
			if (list != null && !list.isEmpty()) {
				num = loanRepayPlanService.insertOrUpdateLoanRepayPlan(list);
			}
			String num_msg = "【还款计划表】插入或更新数据处理结果:" + num;
			logger.info(num_msg, "message{}");
			if (num > 0) {
				result = true;
			}
		} catch (Exception e) {
			e.printStackTrace();
			String tableName = "loan_repay_plan";
			String errorMsg = "同步过来的日初借据分期计划临时表数据修改还款计划表出错！";
			String remark = "同步过来的日初借据分期计划临时表数据修改还款计划表出错，错误信息：" + e.getMessage();
			addErrorInfo(tableName, MonAlrmLvlEnum.SERIOUS.getEnname(), errorMsg, remark);
			logger.error(remark);
		} finally {
			// 清空信息
			list = null;
			txtFileLoadList = null;
		}
		logger.info("同步过来的日初借据分期计划临时表数据修改还款计划表加工处理结束！");
		return result;
	}

	/**
	 * 
	 * 记录异常信息 <br>
	 * 0.1:weijj:2019年5月7日 上午11:31:23:新增 <br>
	 * 
	 * @author weijj
	 * @since 2019年5月7日 上午11:31:23
	 * @date 2019年5月7日 上午11:31:23
	 * @version 0.1
	 */
	private void addErrorInfo(String tableName, String errorType, String errorMsg, String remark) {
		AccoutErroTempVO accoutErroTempVO = new AccoutErroTempVO();
		// 表名
		accoutErroTempVO.setTableName(tableName);
		// 错误级别
		accoutErroTempVO.setErroType(errorType);
		// 错误信息
		accoutErroTempVO.setErroMsg(errorMsg);
		// 备注
		accoutErroTempVO.setRemark(remark);
		// 创建时间
		accoutErroTempVO.setCreateData(DateTool.getCurrentDateTime());
		// 修改时间
		accoutErroTempVO.setLastModifyTime(DateTool.getCurrentDateTime());
		// 记录异常信息
		accoutErroTempService.insert(accoutErroTempVO);
	}
}
